import {BaseEvent, DialogEvent, DialogOpen, MetadataResponse} from "../event-types";
import { DisplayPreparation } from "./display-preparation";

export class DialogPreparation {

    public prepareDialogContent(data: BaseEvent[], metadata: MetadataResponse): DialogEvent[] {
        const dialogs = <DialogOpen[]> data.filter(d => d.EventType === 'DialogEvent');
        const contentPreparation = new DisplayPreparation();
        return dialogs.map(d => {
            return {
                eventType: 'dialog-event',
                timestamp: +d.Timestamp,
                dialogDimensions: {
                    height: d.Event.DialogDimensions.Height,
                    width: d.Event.DialogDimensions.Width,
                    timestamp: +d.Event.DialogDimensions.Timestamp
                },
                content: contentPreparation.contentTransformation(d.Event.Content)
            }
        });
    }
}